package com.turnengine.client.local.upkeep.bean;

import com.javabi.common.io.data.IDataReader;
import com.javabi.common.io.data.IDataWriter;
import java.io.IOException;

/**
 * The Upkeep Serializer.
 */
public class UpkeepSerializer implements IUpkeepSerializer {

	@Override
	public IUpkeep readObject(IDataReader reader) throws IOException {

		// Read fields
		int upkeepId = reader.readInt();
		int priority = reader.readInt();

		// Create object
		IUpkeep object = new Upkeep();
		object.setUpkeepId(upkeepId);
		object.setPriority(priority);
		return object;
	}

	public void writeObject(IDataWriter writer, IUpkeep object) throws IOException {

		// Get fields
		int upkeepId = object.getUpkeepId();
		int priority = object.getPriority();

		// Write fields
		writer.writeInt(upkeepId);
		writer.writeInt(priority);
	}
}
